package com.flyfish.ddns;

import java.io.IOException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import com.flyfish.ddns.timer.SendTimer;
import com.flyfish.ddns.utils.PropertiesUtil;
import com.flyfish.ddns.utils.WriteLog;

/**
 * 运行DDNS检查
 *
 */
public class AppRun {

	private static long waitTime = 300;
	static {
		String time = PropertiesUtil.getProperty("waitTime");
		if (time != null && !time.trim().equals("")) {
			waitTime = Long.parseLong(time.trim());
		}
	}

	public static void main(String[] args) throws IOException {
		try {
			ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
			executorService.scheduleAtFixedRate(new SendTimer(), 0, waitTime * 1000, TimeUnit.MILLISECONDS);
		} catch (Exception e) {
			WriteLog.writeLogInfo("定时器运行发生异常。");
		}
	}
}
